package ws;

import BO.*;
import DB.*;
import UI.*;
import java.util.ArrayList;
import java.util.List;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;


@WebService(serviceName = "RoMaWebService")
@HandlerChain(file = "RoMaWebService_handler.xml")
public class RoMaWebService {

    @WebMethod(operationName="removeFriendship")
    public boolean removeFriendship(@WebParam(name = "requestId") int reqId, @WebParam(name = "reciverId") int recId){
        return Service.removeFriendship(reqId, recId);
    }
    
    @WebMethod(operationName="getFriendStatusUpdates")
    public List<StatusUI> getFriendStatusUpdates(@WebParam(name = "requestId") int id){
        return Service.getFriendStatusUpdates(id);
    }
    
    @WebMethod(operationName="getUserFriends")
    public List<UserUI> getUserFriends(@WebParam(name = "userId") int userId){
        return Service.getUserFriends(userId);
    }
    
    @WebMethod(operationName="addFriendship")
    public boolean addFriendship(@WebParam(name = "requestId") int requester, @WebParam(name = "reciverId") int receiver){
        return Service.addFriendship(requester, receiver);
    }
    
    @WebMethod(operationName="getReceivedPrivateMessages")
    public List<PMUI> getReceivedPrivateMessages(@WebParam(name = "user") UserUI user) {
        return Service.getReceivedPrivateMessages(user);
    }
    
    @WebMethod(operationName="getSentPrivateMessages")
    public List<PMUI> getSentPrivateMessages(@WebParam(name = "user") UserUI user) {
        return Service.getSentPrivateMessages(user);
    }
    
    @WebMethod(operationName="addInterest")
    public boolean addInterest(@WebParam(name = "userId") int id, @WebParam(name = "interestName") String newInterest) {
        return Service.addInterest(id, newInterest);
    }
    
    @WebMethod(operationName="getUserNamesLike")
    public List<String> getUserNamesLike(@WebParam(name = "query") String query) {
        return Service.getUserNamesLike(query);
    }
    
    @WebMethod(operationName="getUserInterests")
    public List<InterestUI> getUserInterests(@WebParam(name = "userId") int userId) {
        return Service.getUserInterests(userId);
    }

    @WebMethod(operationName="sendPrivateMessage")
    public boolean sendPrivateMessage(@WebParam(name = "receivername") String receivername, @WebParam(name = "message") String message, @WebParam(name = "senderId") int id){
        return Service.sendPrivateMessage(receivername, message, id);
    }
    
    @WebMethod(operationName="getChatByID")
    public UI.ChatUI getChatByID(@WebParam(name = "chatId") int id) {
        return Service.getChatByID(id);
    }
    
    @WebMethod(operationName = "createChatMessage")
    public boolean createChatMessage(@WebParam(name = "chatId")int chatId, @WebParam(name = "message")String message,@WebParam(name = "userId") int userId) {
        return Service.createChatMessage(chatId, message, userId); 
    }

    @WebMethod(operationName ="registerUser")
    public static UserUI registerUser(@WebParam(name = "name")String name,@WebParam(name = "email") String email,@WebParam(name = "password") String password) {
        return Service.registerUser(name,email,password);
    }

    @WebMethod(operationName = "validateUser")
    public static UserUI validateUser(@WebParam(name = "name")String name,@WebParam(name = "password") String password) {
        return Service.validateUser(name,password);
    }

    @WebMethod(operationName = "getStatusUpdates")
    public ArrayList<StatusUI> getStatusUpdates(@WebParam(name = "id")int id) {
        return Service.getStatusUpdates(id);
    }

    @WebMethod(operationName = "addStatusMessage")
    public boolean addStatusMessage(@WebParam(name = "id")int id, @WebParam(name = "statusMessage")String statusMessage) {
        return Service.addStatusMessage(id,statusMessage);
    }
    
    @WebMethod(operationName = "getUser")
    public UserUI getUser(@WebParam(name = "id")int id) {
        return Service.getUser(id);
    }

    @WebMethod(operationName="searchAfterUser")
    public List<UserUI> searchAfterUser(@WebParam(name = "chatId") String search) {
        return Service.searchAfterUser(search);
    }
}